package com.jk.mapper;

import com.jk.vo.CouponInfo;
import com.jk.vo.ProductInfo;
import com.jk.vo.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface EnterpriseMapper {
    @Insert("insert into coupon_info (coupon_id, coupon_over_time, coupon_type,coupon_count," +
            "coupon_quota,coupon_min_aoc,coupon_create_time,coupon_status,coupon_start_time,user_id)" +
            "values (#{couponId},#{couponOverTime},#{couponType},#{couponCount},#{couponQuota},#{couponMinAoc}" +
            ",#{couponCreateTime},#{couponStatus},#{couponStartTime},#{userId})")
    int insertCouponInfo(CouponInfo couponInfo);
    @Insert("insert into product_info (product_id,product_name,product_price,product_type,product_status," +
            "user_id) values (#{productId},#{productName},#{productPrice},#{productType},#{productStatus},#{userId})")
    int insertProductInfo(ProductInfo productInfo);

    /**
     * 查询总条数totalCount
     * @return
     */
    @Select("select count(1) from product_info")
    int selectTotalCount();

    /**
     * 分页查询商品信息
     * @param start
     * @param end
     * @return
     */
    @Select("select * from product_info limit #{start},#{end}")
    @Results({
            @Result(id=true,column="product_id",property = "productId"),
            @Result(column = "product_name",property = "productName"),
            @Result(column = "product_price",property = "productPrice"),
            @Result(column = "product_type",property = "productType"),
            @Result(column = "product_status",property = "productStatus"),
            @Result(column = "user_id",property = "userId"),
    })
    List<ProductInfo> selectProductInfo(@Param("start") int start, @Param("end") int end);

    /**
     * 查询企业用户信息
     * @param userId
     * @return
     */
    @Select("select * from user_login where user_id = #{userId}")
    @Results({
            @Result(id=true,column="user_id",property = "userId"),
            @Result(column = "user_name",property = "userName"),
            @Result(column = "user_pwd",property = "userPwd"),
            @Result(column = "registetime",property = "registetime"),
            @Result(column = "user_type",property = "userType"),
            @Result(column = "user_status",property = "userStatus"),
            @Result(column = "user_number",property = "userNumber")
    })
    UserInfo selectEnterpriseInfo(String userId);
}
